//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for KinesisAnalytics
public struct KinesisAnalyticsErrorType: AWSErrorType {
    enum Code: String {
        case codeValidationException = "CodeValidationException"
        case concurrentModificationException = "ConcurrentModificationException"
        case invalidApplicationConfigurationException = "InvalidApplicationConfigurationException"
        case invalidArgumentException = "InvalidArgumentException"
        case limitExceededException = "LimitExceededException"
        case resourceInUseException = "ResourceInUseException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case resourceProvisionedThroughputExceededException = "ResourceProvisionedThroughputExceededException"
        case serviceUnavailableException = "ServiceUnavailableException"
        case tooManyTagsException = "TooManyTagsException"
        case unableToDetectSchemaException = "UnableToDetectSchemaException"
        case unsupportedOperationException = "UnsupportedOperationException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize KinesisAnalytics
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// User-provided application code (query) is invalid. This can be a simple syntax error.
    public static var codeValidationException: Self { .init(.codeValidationException) }
    /// Exception thrown as a result of concurrent modification to an application. For example, two individuals attempting to edit the same application at the same time.
    public static var concurrentModificationException: Self { .init(.concurrentModificationException) }
    /// User-provided application configuration is not valid.
    public static var invalidApplicationConfigurationException: Self { .init(.invalidApplicationConfigurationException) }
    /// Specified input parameter value is invalid.
    public static var invalidArgumentException: Self { .init(.invalidArgumentException) }
    /// Exceeded the number of applications allowed.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// Application is not available for this operation.
    public static var resourceInUseException: Self { .init(.resourceInUseException) }
    /// Specified application can't be found.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// Discovery failed to get a record from the streaming source because of the Amazon Kinesis Streams ProvisionedThroughputExceededException. For more information, see GetRecords in the Amazon Kinesis Streams API Reference.
    public static var resourceProvisionedThroughputExceededException: Self { .init(.resourceProvisionedThroughputExceededException) }
    /// The service is unavailable. Back off and retry the operation.
    public static var serviceUnavailableException: Self { .init(.serviceUnavailableException) }
    /// Application created with too many tags, or too many tags added to an application. Note that the maximum number of application tags includes system tags. The maximum number of user-defined application tags is 50.
    public static var tooManyTagsException: Self { .init(.tooManyTagsException) }
    /// Data format is not valid. Amazon Kinesis Analytics is not able to detect schema for the given streaming source.
    public static var unableToDetectSchemaException: Self { .init(.unableToDetectSchemaException) }
    /// The request was rejected because a specified parameter is not supported or a specified resource is not valid for this operation.
    public static var unsupportedOperationException: Self { .init(.unsupportedOperationException) }
}

extension KinesisAnalyticsErrorType: Equatable {
    public static func == (lhs: KinesisAnalyticsErrorType, rhs: KinesisAnalyticsErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension KinesisAnalyticsErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
